import '../model/result_model.dart';
import '../model/test_batch_model.dart';
import '../utils/request.dart';

///考试批次接口
class TestBatchApi {
  TestBatchApi._();

  static final _singleton = TestBatchApi._();

  factory TestBatchApi() => _singleton;

  ///查询
  Future<TestBatchQueryRes> query(final TestBatchQueryReq req) =>
      request
          .getHandler(path: '/${req.tenantId}/test-batch', params: req.toMap())
          .then((res) => TestBatchQueryRes.fromModel(res));

  ///加载
  Future<TestBatchInfoRes> info(final String id) => request
      .getHandler(path: '/test-batch/$id')
      .then((res) => TestBatchInfoRes.fromModel(res));

  ///新增
  Future<BaseModelRes> add(final TestBatchAddReq req) => request
      .postHandler(path: '/${req.tenantId}/test-batch', data: req.toMap());

  ///修改
  Future<BaseModelRes> modify(final TestBatchModifyReq req) =>
      request.putHandler(path: '/test-batch/${req.id}', data: req.toMap());

  ///删除
  Future<BaseModelRes> delete(final String id) =>
      request.deleteHandler(path: '/test-batch/$id');
}

///考试批次接口单例
final testBatchApi = TestBatchApi();
